unit uCadastroPlanos;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uCadastroGenerico, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinOffice2007Black, dxSkinOffice2007Blue,
  dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver, 
  dxSkinsdxBarPainter, StdCtrls, Mask, DBCtrls, ZSequence, DB, ZAbstractRODataset,
  ZAbstractDataset, ZAbstractTable, ZDataset, dxBar, cxClasses, ActnList, ImgList, ExtCtrls,
  dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver,
  cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxContainer,
  cxEdit, cxTextEdit, cxMaskEdit, cxDBEdit, cxCurrencyEdit;

type
  TfCadastroPlanos = class(TfCadastroGenerico)
    gbPlano: TGroupBox;
    lbl1: TLabel;
    lbl2: TLabel;
    lbl3: TLabel;
    lbl4: TLabel;
    lbl5: TLabel;
    lbl6: TLabel;
    lbl7: TLabel;
    lblDuracao: TLabel;
    lbl9: TLabel;
    lbl10: TLabel;
    dbedtcod_Plano: TDBEdit;
    dbedtNomePlano: TDBEdit;
    dbmedtValorMensal: TcxDBCurrencyEdit;
    dbmedtAcrescimoDep: TcxDBCurrencyEdit;
    dbmedtAcrescimoIdade: TcxDBCurrencyEdit;
    dbmedtDuracao: TcxDBMaskEdit;
    dbmedtCarencia: TcxDBMaskEdit;
    dbmedtNDependentes: TcxDBMaskEdit;
    dbmedtValorTotal: TcxDBCurrencyEdit;
    procedure FormShow(Sender: TObject);
    procedure actAdicionarExecute(Sender: TObject);
    procedure dbmedtValorMensalPropertiesChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fCadastroPlanos: TfCadastroPlanos;

implementation

{$R *.dfm}

procedure TfCadastroPlanos.actAdicionarExecute(Sender: TObject);
begin
  inherited;
  dbedtcod_Plano.ReadOnly:= false;
  dbedtcod_Plano.Text := IntToStr(seqCadastro.GetNextValue);
  dbedtcod_Plano.ReadOnly:= true;
end;



procedure TfCadastroPlanos.dbmedtValorMensalPropertiesChange(Sender: TObject);
var
  meses: Integer;
  valor : Currency;

begin
  inherited;
  if TryStrToCurr(dbmedtValorMensal.Text,valor) and TryStrToInt(dbmedtDuracao.Text,meses) then
    dbmedtValorTotal.Value := valor*meses;

end;


procedure TfCadastroPlanos.FormShow(Sender: TObject);
begin
  inherited;
      if Modo <> MCEdita then
  begin
   dbedtcod_Plano.Text := IntToStr(seqCadastro.GetNextValue);
   dbedtcod_Plano.ReadOnly:= true;
  end;
end;

end.
